{include file="common/comm_header" /}

<body class="login-bg">
    
    <div class="login layui-anim layui-anim-up">
        <div class="message">管理员登录</div>
        <div id="darkbannerwrap"></div>
        
        <form method="post" class="layui-form" action="">
            <input name="password" lay-verify="required" placeholder="密码"  type="password" class="layui-input">
            <hr class="hr15">
            <input value="登录" id="loginSub" lay-submit lay-filter="login" style="width:100%;" type="button">
            <hr class="hr20" >
        </form>
    </div>


    <script type="text/javascript" src="/static/common/js/jquery.min.js"></script>
    <script src="/static/admin/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/admin/js/xadmin.js"></script>

    <script>
        $(function  () {

            if(top.location != self.self.location){  //判断是否存在父窗口
                top.location.reload();
            }

            layui.use('form', function(){
                var form = layui.form;
                //自定义验证规则
                form.verify({
                });
                //监听提交
                form.on('submit(login)', function(data){
                    $('#loginSub').attr('disabled',true);
                    $.ajax({
                        url:"/{$Think.ADMIN_ROUT_PREFIX}/login/"+Math.random(),
                        timeout : 3000,
                        type : 'post',
                        data :{password:data.field.password},
                        async: false,
                        dataType:'json',
                        success:function(data){
                            if(data.code == 1){
                                layer.alert(data.msg, {
                                    icon: 6,
                                    time: 1500,
                                    closeBtn:0,
                                    end:function () {
                                        window.location.href=data.url;
                                    }
                                });
                            }else if(data.code == 0){
                                layer.alert(data.msg, {
                                    icon: 5,
                                    time: 2000
                                });
                                $('#loginSub').attr('disabled',false);
                                return false;
                            }else{
                                layer.alert('出现异常，建议刷新页面.', {
                                    icon: 5,
                                    time: 2000
                                });
                                $('#loginSub').attr('disabled',false);
                                return false;
                            }
                        },
                        error:function(){
                            layer.alert('出现异常，建议刷新页面。', {
                                icon: 5,
                                time: 2000
                            });
                            $('#loginSub').attr('disabled',false);
                            return false;
                        }
                    });

                    return false;
                });
            });
        })


    </script>

    <!-- 底部结束 -->
</body>

{include file="common/comm_bottom" /}